import sys

def main(argv=None):

    id = email = idCard = name = ""
    while True:
        id = input("请输入id:")
        if checkId(id):
            break

    while True:
        email = input("请输入邮箱:")
        if checkEmail(email):
            break

    while True:
        idCard = input("请输入身份证号:")
        if checkIdCard(idCard):
            break

    while True:
        name = input("请输入姓名:")
        if checkIdName(name):
            break
        
    print("==========输入完成===========")


# 验证id 长度不能超过8位，且只能由数字、字母、下划线组成
def checkId(id):
    if len(id) >= 8 or len(id) < 1:
        print("不符合，请重新输入id")
        return False
    else:
        return True

# 验证邮箱
def checkEmail(email):
    index1=email.find("@") 
    index2=email.find(".") 
    if index1==-1: 
        print("邮箱地址必须包括@")
        return False
    elif index2==-1: 
        print("邮箱地址必须包括.")
        return False
    elif index2<index1: 
        print("邮箱地址的最后一个.在@之后")
        return False
    elif index2==len(email)-1: 
        print("最后一个.后面要有其他字符")
        return False
    else: 
        return True

# 验证身份证
def checkIdCard(numbers):
    l1 = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
    s = 0
    for index, number in enumerate(numbers[:-1]):
        s += l1[index] * int(number)
    l2 = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2']
    if numbers[-1] == l2[s % 11]:
        return True
    else:
        print('身份证输入错误')
        return False

# 验证名字为中文切不能超4位
def checkIdName(name):
    if len(name)> 4:
        print("名字不能超过4位")
    
    for ch in name:
        if u'\u4e00' <= ch <= u'\u9fff':
            return True
        else:
            print("名字必须为中文")
            return False
    

if __name__=="__main__":
    sys.exit(main())
